import request from '@/utils/request';
import { convertPageInfo, convertPostList } from '@/api/formatter';

//根据关键字和分页数据来获取文章列表信息
export function getPostListByKeywords(
    keywords: string,
    pageSize: number,
    pageIndex = 1
) {
    if (!pageIndex) {
        pageIndex = 1;
    }
    return request({
        url: '/news/newsList',
        method: 'GET',
        params: {
            name: keywords,
            page: pageIndex,
            limit: pageSize,
        },
    }).then((data: any) => {
        return {
            postList: convertPostList(data),
            pageInfo: convertPageInfo(data),
        };
    });
}
